package com.autonavi.yunda.yunji.core.enums;

import lombok.Getter;

/**
 * @author sunzhenbang
 * @date 2022/10/25 14:29
 */
public interface OperationRecordType {
    String getType();

    String getOperation();

    enum Type {
        PROJECT("project", "项目"),
        DATABASE("database", "数据库"),
        USER("user", "用户"),
        FUNCTION("function", "函数"),
        INTERFACE("interface", "接口"),
        DYNAMIC("dynamic", "变量"),
        COMPONENTSUBTYPE("componentSubType", "组件"),
        TASK("task", "任务"),
        JOB_ADMIN("job_admin", "任务管理")
        ;

        Type(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Getter
        private final String code;
        @Getter
        private final String desc;
    }

    enum DynamicSubType implements OperationRecordType {
        UPDATE("update", "修改"),
        CREATE("create", "创建"),
        ;
        @Getter
        private final String code;
        @Getter
        private final String desc;

        DynamicSubType(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public String getType() {
            return Type.DYNAMIC.code;
        }

        @Override
        public String getOperation() {
            return this.getCode();
        }
    }

    enum ProjectSubType implements OperationRecordType {
        UPDATE("update", "修改"),
        CREATE("create", "创建"),
        DELETE("delete", "删除"),
        TEST("test", "提交测试"),
        EXPORT("export", "导出"),
        ;
        @Getter
        private final String code;
        @Getter
        private final String desc;

        ProjectSubType(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public String getType() {
            return Type.PROJECT.code;
        }

        @Override
        public String getOperation() {
            return this.getCode();
        }
    }

    enum ComponentSubType implements OperationRecordType {
        CREATE("create", "创建"),
        UPDATE("update", "更新"),
        DELETE("delete", "删除"),
        SYNC("sync", "同步"),
        PUBLISH("publish", "发布"),
        SUBMIT_SHELF("submitShelf", "提交上架");
        @Getter
        private final String code;
        @Getter
        private final String desc;

        ComponentSubType(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public String getType() {
            return Type.COMPONENTSUBTYPE.code;
        }

        @Override
        public String getOperation() {
            return this.getCode();
        }
    }

    enum UserSubType implements OperationRecordType {
        CREATE("create", "创建"),
        UPDATE("update", "修改"),
        ;
        @Getter
        private final String code;
        @Getter
        private final String desc;

        UserSubType(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public String getType() {
            return Type.USER.code;
        }

        @Override
        public String getOperation() {
            return this.getCode();
        }
    }

    enum DatabaseSubType implements OperationRecordType {
        UPDATE("update", "修改"),
        CREATE("create", "创建"),
        DELETE("delete", "删除"),
        ;
        @Getter
        private final String code;
        @Getter
        private final String desc;

        DatabaseSubType(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public String getType() {
            return Type.DATABASE.getCode();
        }

        @Override
        public String getOperation() {
            return this.getCode();
        }
    }

    enum FunctionSubType implements OperationRecordType {
        UPDATE("update", "修改"),
        PUBLISH("publish", "发布"),
        OFFLINE("offline", "下线"),
        CREATE("create", "创建"),
        DELETE("offline", "下线"),
        DEBUG("debug", "修改"),
        ;
        @Getter
        private final String code;
        @Getter
        private final String desc;

        FunctionSubType(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public String getType() {
            return Type.FUNCTION.getCode();
        }

        @Override
        public String getOperation() {
            return this.getCode();
        }
    }

    enum InterfaceSubType implements OperationRecordType {
        UPDATE("update", "修改"),
        CREATE("create", "创建"),
        UPGRADE("upgrade", "升级"),
        OFFLINE("offline", "下线"),
        DELETE("delete", "删除"),
        CONVERT_TO_COMPONENT("convertToComponent", "转为零部件"),
        PUBLISH("publish", "全量发布"),
        ENTER_VALIDATING("enterValidating", "待验证"),
        GRAY_PUBLISH("grayPublish", "灰度发布"),
        CANCEL_GRAY_PUBLISH("cancelGrayPublish", "取消灰度"),
        DEBUG_ALL_NODE("debugAllNode", "调试全链路"),
        DEBUG_SINGLE_NODE("debugSingleNode", "调试单节点"),
        FORCE_TEST_SUCCESS("forceTestSuccess", "强制调试成功"),
        EXPOSED_RESTAPI("exposedRestapiSuccess", "透出公网"),
        REVOKE_EXPOSED_RESTAPI("exposedRestapiSuccess", "撤销透出公网")
        ;
        @Getter
        private final String code;
        @Getter
        private final String desc;

        InterfaceSubType(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public String getType() {
            return Type.INTERFACE.getCode();
        }

        @Override
        public String getOperation() {
            return this.getCode();
        }
    }

    @Getter
    enum TaskSubType implements OperationRecordType {
        UPDATE("update", "修改"),
        CREATE("create", "创建"),
        DEBUG_ALL_NODE("debugAllNode", "调试全链路"),
        DEBUG_SINGLE_NODE("debug", "单节点调试"),
        ENTER_VALIDATING("enterValidating", "待验证"),
        PUBLISH("publish", "发布"),
        OFFLINE("offline", "下线"),
        ;
        private final String code;
        private final String desc;

        TaskSubType(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public String getType() {
            return Type.TASK.code;
        }

        @Override
        public String getOperation() {
            return this.getCode();
        }
    }

    @Getter
    enum JobInfoType implements OperationRecordType {
        ADD("add","新建任务"),
        TRIGGER("trigger","执行一次"),
        START("start","启动"),
        STOP("stop","停止"),
        UPDATE("update","编辑"),
        REMOVE("remove","删除");

        private final String code;
        private final String desc;

        JobInfoType(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public String getType() {
            return Type.JOB_ADMIN.code;
        }

        @Override
        public String getOperation() {
            return this.getCode();
        }
    }
}
